<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>寒衣补助申请系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <!--所有的静态资源文件默认再 static下-->
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/login.css" media="all">
</head>
<body style="background-image: url('/img/0.jpg');background-size: cover">

<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">

    <div class="layadmin-user-login-main">
        <div class="layadmin-user-login-box layadmin-user-login-header">
            <h2>寒衣补助申请系统</h2>
            <p>友情支持-成都上程数据有限公司</p>
        </div>
        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-username"></label>
                <input type="text" name="sn" id="LAY-user-login-username" value="10266" lay-verify="required" placeholder="工号/学号" class="layui-input">
                <!--<input type="text" name="sn" id="LAY-user-login-username" value="0121603490318" lay-verify="required" placeholder="工号/学号" class="layui-input">-->
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-password"></label>
                <input type="text" name="name" id="LAY-user-login-password" value="张晓文" lay-verify="required" placeholder="姓名" class="layui-input">
                <!--<input type="text" name="name" id="LAY-user-login-password" value="各帅帅" lay-verify="required" placeholder="姓名" class="layui-input">-->
            </div>
            <div class="layui-form-item" style="margin-bottom: 20px;">
                <input type="checkbox" name="remember" lay-skin="primary" title="记住密码">
                <a href="forget.html" class="layadmin-user-jump-change layadmin-link" style="margin-top: 7px;">忘记密码？</a>
            </div>
            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-login-submit">登 入</button>
            </div>
            <div class="layui-trans layui-form-item layadmin-user-login-other">
                <a href="reg.html" class="layadmin-user-jump-change layadmin-link">注册帐号</a>
            </div>
        </div>
    </div>

    <div class="layui-trans layadmin-user-login-footer">

        <p>Copyright© suncaper </p>
        <p>蜀ICP备2021022703号</p>
    </div>

</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'user'], function(){
        var $ = layui.$
            ,setter = layui.setter
            ,admin = layui.admin
            ,form = layui.form
            ,router = layui.router()
            ,search = router.search;

        form.render();

        //提交
        form.on('submit(LAY-user-login-submit)', function(obj){
            console.info(obj)
            var data = obj.field
            //请求登入接口
            $.ajax({
                type: "post",
                url: "/user/login",
                data: obj.field,
                success: function (res) {
                    if(res.data == null){
                        layer.msg("请输入正确的用户名或密码",{icon: 5})
                    }else{
                        layer.msg("登录成功",{icon: 6,time: 1000},function () {
                            //理应跳转到主页，但是templates路径和WEB-INF目录一样，只能通过请求转发过去
                            window.location = "/index"
                        })
                    }
                }
            })

        });
    });
</script>
</body>
</html>